{% extends 'base.html' %}

{% block content %}
    <div class="row mb-4">
        <div class="col-md-12">
            <h1>创建新问题</h1>
        </div>
    </div>

    <div class="card">
        <div class="card-header">
            <h5>问题信息</h5>
        </div>
        <div class="card-body">
            <form method="post" action="{{ url_for('main.create_issue') }}">
                <div class="form-group">
                    <label for="title">标题 <span class="text-danger">*</span></label>
                    <input type="text" class="form-control" id="title" name="title" required>
                </div>

                <div class="form-group">
                    <label for="description">描述</label>
                    <textarea class="form-control" id="description" name="description" rows="5"></textarea>
                </div>
                
                <div class="form-group">
                    <label for="files">上传文件 (支持图片、视频、语音、文档等)</label>
                    <input type="file" class="form-control" id="files" name="files" multiple accept="image/*,video/*,audio/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt">
                    <small class="form-text text-muted">支持多种文件格式，可选择多个文件。</small>
                </div>

                <div class="form-row">
                    <div class="form-group col-md-4">
                        <label for="priority">优先级 <span class="text-danger">*</span></label>
                        <select class="form-control" id="priority" name="priority" required>
                            <option value="low">低</option>
                            <option value="medium" selected>中</option>
                            <option value="high">高</option>
                            <option value="urgent">紧急</option>
                        </select>
                    </div>

                    <div class="form-group col-md-4">
                        <label for="due_date">截止日期</label>
                        <input type="date" class="form-control" id="due_date" name="due_date">
                    </div>

                    <div class="form-group col-md-4">
                        <label for="category">分类</label>
                        <select class="form-control" id="category" name="category">
                            <option value="">未分类</option>
                            <option value="bug">Bug</option>
                            <option value="feature">功能需求</option>
                            <option value="task">任务</option>
                            <option value="question">问题咨询</option>
                        </select>
                    </div>
                </div>

                <div class="form-row">
                    <div class="form-group col-md-4">
                        <label for="assignee">分配给</label>
                        <select class="form-control" id="assignee" name="assignee">
                            <option value="">未分配</option>
                            {% for user in all_users %}
                            <option value="{{ user.id }}">{{ user.username }}</option>
                            {% endfor %}
                        </select>
                    </div>

                    <div class="form-group col-md-4">
                        <label for="milestone">里程碑</label>
                        <select class="form-control" id="milestone" name="milestone">
                            <option value="">未设置</option>
                            {% for milestone in all_milestones %}
                            <option value="{{ milestone.id }}">{{ milestone.name }}</option>
                            {% endfor %}
                        </select>
                    </div>

                    <div class="form-group col-md-4">
                        <label for="visibility">可见性</label>
                        <select class="form-control" id="visibility" name="visibility" required>
                            <option value="public" selected>公开</option>
                            <option value="private">私有</option>
                            <option value="internal">内部</option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label>标签</label>
                    <div class="form-check">
                        {% for tag in all_tags %}
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="checkbox" id="tag-{{ tag.id }}" name="tags" value="{{ tag.id }}">
                            <label class="form-check-label" for="tag-{{ tag.id }}">{{ tag.name }}</label>
                        </div>
                        {% endfor %}
                    </div>
                </div>

                <button type="submit" class="btn btn-primary">创建问题</button>
                <a href="{{ url_for('main.list_issues') }}" class="btn btn-secondary ml-2">取消</a>
            </form>
        </div>
    </div>
{% endblock %}